﻿using VisionDesigner.CircleFind;
using VM.Common.Helper;
using System;

namespace VM.Modules.CircleFinding
{
    /// <summary>
    /// 圆检测结果类，存储检测到的圆的属性和质量指标
    /// </summary>
    [Serializable]
    public class ResultCircle : NotifyPropertyBase
    {
        #region 圆基本属性

        private double _CenterX;
        /// <summary>
        /// 圆心坐标X（像素）
        /// </summary>
        public double CenterX
        {
            get => _CenterX;
            set => Set(ref _CenterX, value);
        }

        private double _CenterY;
        /// <summary>
        /// 圆心坐标Y（像素）
        /// </summary>
        public double CenterY
        {
            get => _CenterY;
            set => Set(ref _CenterY, value);
        }

        private double _Radius;
        /// <summary>
        /// 圆半径（像素）
        /// </summary>
        public double Radius
        {
            get => _Radius;
            set => Set(ref _Radius, value);
        }

        #endregion

        #region 圆质量指标

        private double _circleness;
        /// <summary>
        /// 圆度值，表示检测点与拟合圆的符合程度
        /// </summary>
        public double Circleness
        {
            get => _circleness;
            set => Set(ref _circleness, value);
        }

        private double _circleAreaRate;
        /// <summary>
        /// 圆面积度，表示检测区域内符合圆特性的面积比例
        /// </summary>
        public double CircleAreaRate
        {
            get => _circleAreaRate;
            set => Set(ref _circleAreaRate, value);
        }

        #endregion

        #region 方法

        /// <summary>
        /// 从圆检测结果更新当前对象的属性
        /// </summary>
        /// <param name="result">圆检测结果对象</param>
        public void UpdateResult(CCircleFindResult result)
        {
            if (result == null)
                return;

            CenterX = result.Circle.Center.fX;
            CenterY = result.Circle.Center.fY;
            Radius = result.Circle.Radius;
            Circleness = result.Circleness;
            CircleAreaRate = result.CircleAreaRate;
        }

        #endregion
    }
}